import { fail, success } from './_utils'

export default [
  {
    url: '/api/user/login',
    method: 'post',
    response: ({ _query }) => {
      // const { username, password } = JSON.parse(params.body);
      const username = 'admin'
      const password = 'admin'
      if (!username) {
        return fail('用户名不能为空')
      }
      if (!password) {
        return fail('密码不能为空')
      }
      if (username === 'admin' && password === 'admin') {
        // window.localStorage.setItem('userRole', 'admin');
        return success({
          token: '12345',
        })
      }
      return fail('账号或者密码错误')
    },
  },
  {
    url: '/api/auth/user/info',
    response: ({ _query }) => {
      return success({
        name: '系统管理员',
        avatar: 'https://dummyimage.com/300.png/09f/fff',
        email: 'wangliqun@email.com',
        job: 'frontend',
        jobName: '前端艺术家',
        organization: 'Frontend',
        organizationName: '前端',
        location: 'beijing',
        locationName: '北京',
        introduction: '人潇洒，性温存',
        personalWebsite: 'https://www.arco.design',
        phone: '150****0000',
        registrationDate: '2013-05-10 12:10:00',
        accountId: '15012312300',
        certification: 1,
        role: 'admin',
      })
    },
  },
]
